<%@ page language="java" import="java.util.*,database.*,shopping.*" pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  <body>
   <%String email = request.getParameter("txtEmail"); 
    String userName = request.getParameter("txtNickName");
    String passWord = request.getParameter("txtPassword");
    String repPassWord = request.getParameter("txtRepeatPass");
    System.out.println(email + "  " + userName + "  " + passWord + " " + repPassWord);
    if (userName.trim().length() < 1 && passWord.trim().length() < 1 && repPassWord.trim().length() < 1 && repPassWord.trim().length() < 1)
    {
        response.sendRedirect("reg.jsp?message=must not notthing in all textes!");
    }
    if (! passWord.equals(repPassWord))
    {
      response.sendRedirect("reg.jsp?message=the two passwords are different");
      return ;
    }
     Customer customer = new Customer(userName);
     if (GetData.hasCustomer(userName,passWord) != null)
     {
      response.sendRedirect("reg.jsp?message=the user exists");
      return ;
     }
     customer.setEmail(email);
     customer.setPwd(passWord);
     if ( new InputData().insertCustomer(customer))
     {
        session.setAttribute("customerId", customer.getCustomerId());
        response.sendRedirect("../index.jsp");
        return ;
     }
   %>
  </body>
</html>
